package com.varton.v2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class CountTimeHandler implements InvocationHandler{

    private Runnable runner;

    public CountTimeHandler(Runnable runner) {
        this.runner = runner;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        method.invoke(runner,args);
        long end = System.currentTimeMillis();
        System.out.println(proxy.getClass());
        System.out.println("take time: "+(end-start)+"ms");
        return null;
    }
}
